home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / CSMP Digests / csmp-v1-014.txt < prev    next >
Encoding:
Text File  |  1992-11-18  |  33.6 KB  |  931 lines  |  [TEXT/MPS ]

  1. C.S.M.P. Digest             Wed, 11 Mar 92       Volume 1 : Issue 14
  2.  
  3. Today's Topics:
  4.  
  5.     Accessing individual objects in Think C 5.0.2
  6.     Public domain word format???
  7.     SndStartFilePlay snippet fails, help requested
  8.     Classics And Double Buffered Sounds
  9.     Fast Graphics (Non-Quickdraw)
  10.  
  11.  
  12. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  13.  
  14. These digests are available (by using FTP, account anonymous, your email
  15. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  16. edu (try skinner.cs.uoregon.edu if that doesn't work).  This is also the home
  17. of the comp.sys.mac.programmer Frequently Asked Questions list.
  18.  
  19. The articles in these digests are taken directly from comp.sys.mac.programmer.
  20. They are not edited; all articles included in this digest are in their original
  21. posted form.  The only articles that are -not- included in these digests are
  22. those which didn't receive any replies (except those that give information
  23. rather than ask a question).  All replies to each article are concatenated
  24. onto the original article in the order in which they were received.  Article
  25. threads are not added to the digests until the last article added to the
  26. thread is at least one month old (this is to ensure that the thread is dead
  27. before adding it to the digests).
  28.  
  29. Send administrative mail to mkelly@cs.uoregon.edu.
  30.  
  31. -------------------------------------------------------
  32.  
  33. From: dxandy@cs.widener.edu (Andrew Greenshields)
  34. Subject: Accessing individual objects in Think C 5.0.2
  35. Date: 8 Feb 92 16:43:03 GMT
  36. Organization: Widener University Department of Computer Science, Chester PA
  37.  
  38.  
  39.   I am gradually overcoming the problems I am having in writing my
  40. first real Mac application thanks to the many experts on the net who
  41. have given me invaluable assistance.
  42.  
  43.   I have another question for you all.  My program needs to draw
  44. several identical objects on the screen and then manipulate them
  45. individually.  Each one of these objects has a unique 'label' or ID
  46. which distinguishes it from the others.  I am using the CPane class
  47. for these objects so I can easily intercept clicks in them.  What I
  48. need to know is there any way I can access them individually other
  49. than clicking on them
  50.  
  51.   I had thought about putting them in a linked list, but I wasn't sure
  52. if there was a method that already existed that did what I needed.
  53.  
  54. Thanks!
  55.  
  56. -- 
  57. Andrew J. Greenshields N3IGS |     "It looks like the top part fell on
  58. dxandy@cyber.widener.edu     |        the bottom part." - Dan Quayle     
  59. dxandy@cs.widener.edu        |    ****** STANDARD DISCLAIMERS APPLY ******     
  60. ===============================================================================
  61.  
  62.  
  63.  
  64. - -------------------------
  65.  
  66. From: bernard@moet.cs.colorado.edu (Bernie Bernstein)
  67. Subject:  Accessing individual objects in Think C 5.0.2
  68. Date: 10 Feb 92 19:03:03 GMT
  69. Organization: University of Colorado, Boulder
  70.  
  71. In article <kp824nINNn0u@ashley.cs.widener.edu> dxandy@cs.widener.edu (Andrew Greenshields) writes:
  72. >  I have another question for you all.  My program needs to draw
  73. >several identical objects on the screen and then manipulate them
  74. >individually.  Each one of these objects has a unique 'label' or ID
  75. >which distinguishes it from the others.  I am using the CPane class
  76. >for these objects so I can easily intercept clicks in them.  What I
  77. >need to know is there any way I can access them individually other
  78. >than clicking on them
  79. >
  80. >  I had thought about putting them in a linked list, but I wasn't sure
  81. >if there was a method that already existed that did what I needed.
  82. >
  83.  
  84.  
  85. Every view has a variable 'itsSubviews' which contains the views
  86. within the view. So if you have the pane which encloses the objects
  87. (which can be found in 'itsEnclosure'), you may traverse its subviews
  88. and perform some operation on the objects. Another way to find the
  89. pane if it is the main pane for a document is from the CDocument
  90. 'itsMainPane' variable.
  91.  
  92. So, lets say we have a pane, 'bigPane', which contains some subviews
  93. that we need to traverse, and we want to set the value of my pane's
  94. (of type 'CMyPane') variable 'myVar' to something.
  95.  
  96. ...
  97. bigPane = myDoc->itsMainPane;
  98. if (bigPane->itsSubviews)
  99.      bigPane->itsSubviews->DoForEach1(Change_My_Var, 10L);
  100. ...
  101.  
  102.  
  103. void Change_My_Var(CView *aView, long newValue)
  104. {
  105.      if (member(aView, CMyPane))
  106.           ((CMyPane*)aView)->myVar = newValue;
  107. }
  108.  
  109. >Thanks!
  110. >
  111. >Andrew J. Greenshields N3IGS |     "It looks like the top part fell on
  112. >dxandy@cyber.widener.edu     |        the bottom part." - Dan Quayle     
  113. >dxandy@cs.widener.edu        |    ****** STANDARD DISCLAIMERS APPLY ******     
  114.  
  115. Your welcome.
  116. -- 
  117.       o,  ,,   ,      | Bernie Bernstein                      | ,    ,,
  118.       L>O/  \,/ \    ,| University of Colorado at boulder     |/ \,,/  \
  119.      O./  '  / . `, / | office: (303) 492-8136                |     / ` \  ,.
  120.     ,/   /  ,      '  | email: bernard@cs.colorado.edu        | /        ''  \
  121.  
  122.  
  123.  
  124. ---------------------------
  125.  
  126. From: mmansell@quill.UVic.CA (Mike  Mansell)
  127. Subject: Public domain word format???
  128. Date: 9 Feb 92 20:14:49 GMT
  129. Organization: University of Victoria, Victoria, BC, Canada
  130.  
  131.  
  132.     I'm looking for a non-propreitary format for transmitting
  133. word-processing documents and pictures. I'm also looking for some code
  134. to print these documents. Now, if I can use the code to print but
  135. the format is propreitary, maybe. 
  136.     I've seen a format called Interchange RTF. Does anybody
  137. know anything about this format? Is MacWrite format public?
  138.     I need to be able to save data in a database which can
  139. then be translated back into the orignal document. This data has
  140. tobe able to contain pictures (PICT format).
  141.     I don't know if there is anything available but
  142. if
  143. there is, could someone please let me know.
  144. Thanks.
  145.  
  146.                         Michael Mansell
  147.                         Computer Engineering
  148.                         University of Victoria
  149.                         mmansell@nero.UVic.CA
  150.  
  151.  
  152.  
  153. - -------------------------
  154.  
  155. From: ksand@apple.com (Kent Sandvik)
  156. Subject:  Public domain word format???
  157. Date: 10 Feb 92 05:02:22 GMT
  158. Organization: MacDTS Mongols
  159.  
  160. In article <1992Feb9.201449.1082@sol.UVic.CA>, mmansell@quill.UVic.CA (Mike  Mansell) writes:
  161. >     I'm looking for a non-propreitary format for transmitting
  162. > word-processing documents and pictures. I'm also looking for some code
  163. > to print these documents. Now, if I can use the code to print but
  164. > the format is propreitary, maybe. 
  165. >     I've seen a format called Interchange RTF. Does anybody
  166. > know anything about this format? Is MacWrite format public?
  167.  
  168. Don't know if there are any other real standards than ODA,
  169. and boy Mac applications would certainly be big and slow if 
  170. the apps would use ODA (it's one of these OSI/ISO buzzword
  171. standards).
  172.  
  173. I would recommend to stick to RTF until something better comes
  174. along.
  175.  
  176. Kent Sandvik
  177.  
  178.  
  179.  
  180. - -------------------------
  181.  
  182. From: suitti@ima.isc.com (Stephen Uitti)
  183. Subject:  Public domain word format???
  184. Date: 10 Feb 92 15:23:03 GMT
  185. Organization: Interactive Systems, Cambridge, MA 02138-5302
  186.  
  187. In article <1992Feb9.201449.1082@sol.UVic.CA> mmansell@quill.UVic.CA (Mike  Mansell) writes:
  188. >    I'm looking for a non-propreitary format for transmitting
  189. >word-processing documents and pictures. I'm also looking for some code
  190. >to print these documents. Now, if I can use the code to print but
  191. >the format is propreitary, maybe. 
  192. >    I've seen a format called Interchange RTF. Does anybody
  193. >know anything about this format? Is MacWrite format public?
  194.  
  195.     Microsoft's Rich Text Format (RTF) is publicly available.
  196. Last spring, I called Microsoft & they sent me a copy of the spec
  197. for free.  There is also an on-line discussion of how to read
  198. RTF, more or less.  I could probably find a copy & send it.
  199. It's plain text, as I recall.
  200.  
  201.     RTF handles styled text, formatting, and graphics.  It
  202. uses a text based approach for everything.
  203.  
  204.     I wrote an RTF reader in about two months.  RTF writting
  205. would be much easier to do.  RTF does not appear to handle draw
  206. style pictures - that is objects.  It has color or black & white
  207. bitmaps.
  208.  
  209.     If you needed to add some feature to RTF, that only you
  210. needed to read, it could be done easily.  RTF appears to be
  211. extensible.
  212.  
  213. Stephen.
  214. suitti@ima.isc.com
  215.  
  216.  
  217.  
  218. ---------------------------
  219.  
  220. From: newton@cs.utexas.edu (Peter Newton)
  221. Subject: SndStartFilePlay snippet fails, help requested
  222. Date: 9 Feb 1992 20:05:04 -0600
  223. Organization: CS Dept, University of Texas at Austin
  224.  
  225.  
  226. Can anyone help me to get SndStartFilePlay to work?  I found the
  227. snippet below on ftp.apple.com.  I have modified it slightly to
  228. compile under Think C 5.0.1 (4 byte ints used).  The call to
  229. SndStartFilePlay always returns -108 (out of memory).  I have tried
  230. lots of variations (including more memory), but nothing works.  I have
  231. a Mac Plus running 7.0.
  232.  
  233. Thanks.
  234.  
  235. #include    <Resources.h>
  236. #include    <Quickdraw.h>
  237. #include    <Windows.h>
  238. #include    <dialogs.h>
  239. #include    <OSEvents.h>
  240. #include    <Packages.h>
  241. #include    <Sound.h>
  242.  
  243. #define    FALSE            0
  244.  
  245. main()
  246. {
  247.     Point                where = {20,20};
  248.     OSErr                err;
  249.     SFReply                reply;
  250.     short                refnum;
  251.     char*                string;
  252.     
  253.     InitGraf(&qd.thePort);
  254.     FlushEvents(everyEvent, 0);
  255.     InitWindows();
  256.     InitDialogs(nil);
  257.     InitCursor();
  258.     
  259.     string = (char*) "\pPick a SND File";
  260.  
  261.     SFGetFile (where, string, nil, -1, nil, nil, &reply);
  262.     err = FSOpen(reply.fName, reply.vRefNum, &refnum);
  263.     if (err != noErr) Debugger();
  264.  
  265.     err = SndStartFilePlay (nil, refnum, 0,74000, nil, nil, nil, FALSE);
  266.     if (err != noErr) Debugger();
  267.         
  268. }
  269. -- 
  270.  ----
  271. Peter Newton (newton@cs.utexas.edu)
  272.  
  273.  
  274.  
  275. - -------------------------
  276.  
  277. From: newton@cs.utexas.edu (Peter Newton)
  278. Subject:  SndStartFilePlay snippet fails, help requested
  279. Date: 9 Feb 1992 23:53:38 -0600
  280. Organization: CS Dept, University of Texas at Austin
  281.  
  282. > Can anyone help me to get SndStartFilePlay to work?  I found the
  283. > snippet below on ftp.apple.com.  The call to SndStartFilePlay always 
  284. > returns -108 (out of memory).
  285.  
  286. I believe that I have located the problem myself.  Lurking in IM 6, I
  287. see that the play-from-disk routines work only on machines that have
  288. an "Apple Sound Chip."  I guess my Plus lacks one.  Might have to
  289. replace the antique after all...
  290. -- 
  291.  ----
  292. Peter Newton (newton@cs.utexas.edu)
  293.  
  294.  
  295.  
  296. ---------------------------
  297.  
  298. Subject: Classics And Double Buffered Sounds
  299. From: russells@ccu1.aukuni.ac.nz (Russell Street)
  300. Date: Mon, 10 Feb 1992 03:04:16 GMT
  301. Organization: University of Auckland, New Zealand.
  302.  
  303. The double buffering of sound works on all types of Mac with
  304. the new Sounds Manager (system 6.0.7 and later), doesn't it?
  305. (i.e., regardless of the presence of the Sound Chip)
  306.  
  307. If yes, why can't I get the Double Buffering stuff to
  308. go on a Classic, running System 7.0.1*?  The code I am
  309. trying to use is the Double Buffer sample in the DTS
  310. Snippets. It does work on a IIcx, however.
  311.  
  312. Any constructive help appreciated...
  313. - ------------------------------------------------------------
  314. Russell Street (russells@ccu1.aukuni.ac.nz)
  315.     It was the least I could do -- a quantity I specialize in.
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323. ---------------------------
  324.  
  325. From: taihou@iss.nus.sg (Tng Tai Hou)
  326. Subject: Fast Graphics (Non-Quickdraw)
  327. Date: 23 Jan 92 08:05:05 GMT
  328. Organization: Institute of Systems Science, NUS, Singapore
  329.  
  330. After looking at many good and fast color Mac games, I have
  331. come to the conclusion (no-surprise) that the bottleneck
  332. to speed is Quickdraw.
  333.  
  334. Can anyone share experiences on implementing faster graphics
  335. routines on the Mac? I suppose in writing these routines,
  336. one has to forgo flexibility and just concentrate on, say,
  337. 256 colors only, and write superfast polygon fills and
  338. CopyBits8 (for 256 colors) etc etc directly to screen.
  339.  
  340. I plan to write one package soon, but would like input
  341. from the net.
  342.  
  343. I know good folks as Ben Haler (Solarian and LF) must have
  344. written these. But since their livelihood depends on their
  345. code and knowledge, it is understandable they can't share
  346. their work. Unless a miracle happens and everyone is a
  347. Richard Stallman.
  348.  
  349. Hope to hear from you soon. Please post responses to the
  350. newsgroups.
  351.  
  352. Tai Hou
  353. Singapore
  354.  
  355.  
  356.  
  357. - -------------------------
  358.  
  359. From: deadman@garnet.berkeley.edu (Ben Haller)
  360. Subject:  Fast Graphics (Non-Quickdraw)
  361. Date: 23 Jan 92 15:08:14 GMT
  362. Organization: Stick Software
  363.  
  364.  
  365.   Before saying anything else, I would like to say this thread
  366. should probably not be continued on comp.sys.mac.games, anyone
  367. on that group interested in this subject should be reading programmer
  368. already.  Please direct followups to comp.sys.mac.programmer
  369. exclusively.
  370.  
  371. In article <1992Jan23.080505.18182@nuscc.nus.sg>
  372.    taihou@iss.nus.sg (Tng Tai Hou) writes:
  373. >After looking at many good and fast color Mac games, I have
  374. >come to the conclusion (no-surprise) that the bottleneck
  375. >to speed is Quickdraw.
  376.   It is *a* bottleneck.  Depending on the type of game, it isn't
  377. *the* bottleneck.  For some games deciding on the moves for the
  378. computer, or doing collision detection, etc., take much more time.
  379. Even in arcade games (a surprising amount of time is spent on
  380. collision detection in Lunatic Fringe).  Sound is also a bottleneck,
  381. although it's one that it's harder to do anything about...
  382.  
  383. >Can anyone share experiences on implementing faster graphics
  384. >routines on the Mac? I suppose in writing these routines,
  385. >one has to forgo flexibility and just concentrate on, say,
  386. >256 colors only, and write superfast polygon fills and
  387. >CopyBits8 (for 256 colors) etc etc directly to screen.
  388.   This is one approach.  Generality is not impossible; it's
  389. just very very hard.  Limiting yourself to a single monitor
  390. in 8 bit mode makes life a lot simpler.  A lot of programs
  391. use 16 colors because you have to write half as many longwords
  392. to get the same size graphic.
  393.  
  394. >I know good folks as Ben Haller (Solarian and LF) must have
  395. >written these. But since their livelihood depends on their
  396. >code and knowledge, it is understandable they can't share
  397. >their work. Unless a miracle happens and everyone is a
  398. >Richard Stallman.
  399.   Not everyone is a Richard Stallman (not everyone *wants* to
  400. be, either...) but I am quite willing to discuss direct-to-
  401. screen techniques, I'm just not willing to provide any code.
  402. I and others (Juri Munnki, other miscellaneous folks) often
  403. discuss this sort of thing.  You might try looking for old
  404. messages on subjects like direct-to-screen drawing, ShieldCursor,
  405. and related topics.  I don't know if this group is archived
  406. or not, but if it is that would be a good place to look for
  407. old threads.
  408.   If you have more specific questions, shoot.  It's hard to
  409. address such a general question as "What all this about not
  410. using QuickDraw then?" - narrow it down.
  411.  
  412. -Ben Haller (deadman@garnet.berkeley.edu)
  413.  
  414.  
  415.  
  416. - -------------------------
  417.  
  418. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  419. Subject:  Fast Graphics (Non-Quickdraw)
  420. Date: 23 Jan 92 16:22:55 GMT
  421. Organization: Kalamazoo College
  422.  
  423. Ben Haller writes:
  424. >
  425. >You might try looking for old
  426. >messages on subjects like direct-to-screen drawing, ShieldCursor,
  427. >and related topics.
  428. >
  429.  
  430. Would you mind expounding on ShieldCursor?
  431.  
  432. IM I-474 says "If [the cursor and the given rectangle] intersect,
  433. ShieldCursor hides the cursor."
  434.  
  435. * Is it really the intersection of the cursor (its mask?) and the
  436. rectangle, or does it only hide when the hot spot goes inside?
  437.  
  438. * You have to balance ShieldCursor with ShowCursor.  If you call
  439. ShieldCursor more than once, on intersecting rectangles, does it work
  440. appropriately?
  441.  
  442. * Does CopyBits watch for shielded cursors?  If you shield an area, then
  443. call CopyBits on that area, does CopyBits know that it doesn't have to
  444. hide and show the cursor?
  445.  
  446. * Why'd they do this silly thing with the offsetPt, instead of just
  447. asking for the rectangle in global coordinates!?
  448. -- 
  449.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  450.  
  451.  
  452.  
  453. - -------------------------
  454.  
  455. From: taihou@iss.nus.sg (Tng Tai Hou)
  456. Subject: Fast Graphics cont...
  457. Date: 24 Jan 92 01:49:07 GMT
  458. Organization: Institute of Systems Science, NUS, Singapore
  459.  
  460. Another mail I received ...
  461. - ---
  462. >From d88-jwa@nada.kth.se Thu Jan 23 23:46:55 1992
  463. Subject:   Fast Graphics (Non-Quickdraw)
  464. Status: RO
  465.  
  466. One thing about direct-to-screen; as soon as you start copying
  467. "things" around (not single pixels) the overhead of using CopyBits
  468. properly is very slim. CopyBits with no mask region, and same size
  469. rects, and the same ctSeed for the source and destination pixMaps,
  470. and WORD ALIGNMENT ! (Important !) of the pixMaps works very well
  471. indeed. Longword alignment work even slightly better; and if
  472. you happen to be on a '040 you could consider moving an aligned
  473. cache row... (I get carried away :-)
  474.  
  475. Alignment and having the same ctSeed values is everything to
  476. CopyBits, it can make the meek office slave into a roaring brute !
  477. AND the best thing with CopyBits is that it's guaranteed to be
  478. compatible with everything !
  479.  
  480. Sample code should not be needed; I gave you all the buzz words in
  481. my previous mail ! Just arm yourself with Inside Mac I, V and VI,
  482. as well as the TechNotes stack, and check out SysEnvirons (to check
  483. for MMU) SwapMMUMode, 32-bit cleanliness, StripAddress, GetPixMap-
  484. BaseAddress, PixMap32Bit, ... (and of course you would have to
  485. check for 32bit QD versus classic QD as well)
  486.  
  487. ShieldCursor "signals" that an area has been modified; when you do
  488. a direct transfer to screen, you should call ShieldCursor on the
  489. area that's affected, followed by the transfer, followed by a
  490. ShowCursor. This makes Pivots, SCSI screens, virtual screens, ...
  491. work.
  492.  
  493. (Oh, and you'd have to understand about Graphics Devices and the
  494. Color Manager as well, that's two more chapters, apart from the
  495. Color QD chapter of IM V and the QD overview of IM IV) Maybe you
  496. start realizing why there is no "fast" animation package for the
  497. mac ? The truth is that CopyBits _IS_ as fast as it can be and
  498. still be compatible.
  499.  
  500.                         / h+
  501.  
  502. - --
  503.  
  504. My response was:
  505.  
  506. I doubt very much if I want to be all-depth compatible. If I
  507. write a game that runs in 8-bits, I will make sure that it
  508. is either in that mode or it won't run. In which case writing
  509. just for one mode ought to be faster than flexibility.
  510.  
  511. I have also been wondering 'bout double-buffering in terms
  512. of switching pages. If the display cards behave as I
  513. as think they ought to, maybe, just maybe, when turn
  514. it to 4-bits, I can fool the card into believing it has
  515. another buffer, and simply perform page-flips, instead
  516. of zapping entire off-screens to the screen.
  517.  
  518. Think this is possible? The only card that actually has two video
  519. pages is the good old Apple 8-bit Graphics card in 4-bits mode.
  520.  
  521.  
  522. Thanks to Ben who has offered his help.
  523.  
  524.  
  525.  
  526. - -------------------------
  527.  
  528. From: christer@cs.umu.se (Christer Ericson)
  529. Subject:  Fast Graphics cont...
  530. Date: 26 Jan 92 13:55:43 GMT
  531. Organization: Dep. of Info.Proc, Umea Univ., Sweden
  532.  
  533. In <1992Jan24.014907.20747@nuscc.nus.sg> taihou@iss.nus.sg (Tng Tai Hou) writes:
  534.  
  535. >Another mail I received ...
  536. >-----
  537. >From d88-jwa@nada.kth.se Thu Jan 23 23:46:55 1992
  538. >Subject: Re:  Fast Graphics (Non-Quickdraw)
  539. >Status: RO
  540.  
  541. >One thing about direct-to-screen; as soon as you start copying
  542. >"things" around (not single pixels) the overhead of using CopyBits
  543. >properly is very slim. CopyBits with no mask region, and same size
  544. >rects, and the same ctSeed for the source and destination pixMaps,
  545. >and WORD ALIGNMENT ! (Important !) of the pixMaps works very well
  546. >indeed. Longword alignment work even slightly better; and if
  547. >you happen to be on a '040 you could consider moving an aligned
  548. >cache row... (I get carried away :-)
  549. > [...]
  550. >(Oh, and you'd have to understand about Graphics Devices and the
  551. >Color Manager as well, that's two more chapters, apart from the
  552. >Color QD chapter of IM V and the QD overview of IM IV) Maybe you
  553. >start realizing why there is no "fast" animation package for the
  554. >mac ? The truth is that CopyBits _IS_ as fast as it can be and
  555. >still be compatible.
  556.  
  557. The overhead of using CopyBits is not as slim as some people
  558. might want us to think. One can help CopyBits considerably by
  559. doing the things mentioned; having pre-shifted bitmaps (pixmaps)
  560. avoiding clipping by giving an empty mask region and not drawing
  561. into the current grafport. A big timesaver is to get the address
  562. of CopyBits (or StdBits) and call it directly instead of going
  563. through the dispatcher. This goes for all other traps that will
  564. be called in the tightest loop as well. However, after doing
  565. all this one will probably find that it still isn't fast enough.
  566. In the tests that I and a friend of mine made, we could easily get
  567. a 20% increase in performance by substituting CopyBits with our own
  568. routine, which was far from optimal btw.
  569.  
  570. Furthermore, CopyBits is certainly _not_ as fast as it can be!
  571. Obviously code could be unrolled forever to make a routine as fast
  572. as possible, but to be fair it could be hard to fit lots of unrolled
  573. code into ROM. However, there are many minor changes that could
  574. have been made to the CopyBits code to make it run faster; here
  575. are two examples:
  576.  
  577. >From the SE:
  578.  
  579. @1    MOVE.L    -2(A0),D0
  580.     LSR.L    D5,D0
  581.     MOVE.W    D0,(A1)+
  582.     MOVE.L    (A0)+,D0
  583.     LSR.L    D5,D0
  584.     MOVE.W    D0,(A1)+
  585.     DBRA    D1,@1
  586.  
  587. If the first MOVE.L -2(A0),D0 had been changed to MOVE.L (A2)+,D0
  588. (or any other available address register) where A2 = A0 - 2, four
  589. cycles would be saved each time through the loop. For a very
  590. narrow bitmap this could be a loss (due to the setup of the
  591. address register, depending on what the code surrounding this
  592. code looks like -- I can't remember exactly), but for wider bitmaps
  593. it's certainly a gain. So, four cycles aren't much someone says. Well,
  594. for a 64x64 pixel bitmap that's a whopping 4096 cycles, which in
  595. an animation sequence will eat up a lot of the CPU power on a
  596. Mac SE/Plus.
  597.  
  598. >From the IIsi:
  599.  
  600. @1    AND.L    D5,D1
  601. @2    BFEXTU    (A4){D6:32},D0
  602.     ADDA.W    A0,A4
  603.     EOR.L    D7,D0
  604.     AND.L    D1,D0        ;All but the first and last time through
  605.     NOT.L    D1        ;this loop, these four instructions will
  606.     AND.L    (A5),D1        ;add upp to nothing but NOPs. The first
  607.     OR.L    D1,D0        ;and last time, they clip the bitmap row.
  608.     MOVE.L    D0,(A5)
  609.     ADDA.W    A0,A5
  610.     MOVEQ    #-1,D1
  611.     SUBQ    #1,D2
  612.     BGT    @2
  613.     BEQ    @1
  614.     BRA    foo
  615.  
  616. Someone must really think he was clever to come up with this, and
  617. indeed he was. It is really clever in that it is extremely short
  618. but on the other hand it's rather ineffective, and I for one
  619. would rather have speed than cleverness. As can be seen from
  620. inspection of the code it has been folded to handle all cases
  621. of a bitmap row; the left end, the part in-between, and the
  622. right end. By unrolling this code, the in-between part would look
  623. something like
  624.  
  625.     ...
  626. @2      BFEXTU  (A4){D6:32},D0
  627.         ADDA.W  A0,A4
  628.         EOR.L   D7,D0
  629.         MOVE.L  D0,(A5)
  630.         ...
  631.  
  632. Ignoring cache, this would save four instructions for a total gain
  633. of 36 cycles for each long moved in the in-between phase.
  634. In this latter case, since this rewrite would make the code twice
  635. as large, and since there seems to be an abundance of similar
  636. routines sprinkled liberally across the ROM I can somewhat
  637. understand if Apple decided to go for size instead of speed, but
  638. I still can't help thinking of how effective the code _could_
  639. have been.
  640.  
  641. Now to be fair, CopyBits is extremely simple to use. It works on
  642. all machines, it handles different bit depths, it can stretch
  643. bitmaps, et cetera. In general, it'll do just fine. But it can't
  644. be used for any animation other than for very few or small objects
  645. (especially if your animation needs an erase cycle) unless you don't
  646. care for how fast, or rather slow, your animation will be.
  647. By all means, if CopyBits does what you want it to do, use it; just
  648. remember that there are a few cases where it won't -- as Ben Haller,
  649. Joe Holt and others will testify for.
  650.  
  651.  
  652. Christer Ericson --- Internet: christer@cs.umu.se --- tel: +46-90-166794
  653. Department of Computer Science, University of Umea, S-90187 UMEA, SWEDEN
  654.  
  655.  
  656.  
  657. - -------------------------
  658.  
  659. From: wras@ccwf.cc.utexas.edu (Steve Mariotti)
  660. Subject:  Fast Graphics cont...
  661. Date: 31 Jan 92 16:54:20 GMT
  662. Organization: The University of Texas at Austin, Austin TX
  663.  
  664.  
  665. >In <1992Jan24.014907.20747@nuscc.nus.sg> taihou@iss.nus.sg (Tng Tai Hou) writes:
  666. >
  667. >>Another mail I received ...
  668. >>-----
  669. >>From d88-jwa@nada.kth.se Thu Jan 23 23:46:55 1992
  670. >>Subject: Re:  Fast Graphics (Non-Quickdraw)
  671. >>Status: RO
  672. >
  673. >>One thing about direct-to-screen; as soon as you start copying
  674. >>"things" around (not single pixels) the overhead of using CopyBits
  675. >>properly is very slim. CopyBits with no mask region, and same size
  676. >>rects, and the same ctSeed for the source and destination pixMaps,
  677. >>and WORD ALIGNMENT ! (Important !) of the pixMaps works very well
  678. >>indeed. Longword alignment work even slightly better; and if
  679. >>you happen to be on a '040 you could consider moving an aligned
  680. >>cache row... (I get carried away :-)
  681. >> [...]
  682. >>(Oh, and you'd have to understand about Graphics Devices and the
  683. >>Color Manager as well, that's two more chapters, apart from the
  684. >>Color QD chapter of IM V and the QD overview of IM IV) Maybe you
  685. >>start realizing why there is no "fast" animation package for the
  686. >>mac ? The truth is that CopyBits _IS_ as fast as it can be and
  687. >>still be compatible.
  688.  
  689. What about the possibility of doing something as un-IM-compliant as writing
  690. directly to video memory?  I've tried this with a tight loop that does 
  691. nothing but fill an 8 bit screen with a single value (0xAA).  This is not
  692. as instantaneous as I thought!  In fact, it seems that doing a CopyBits of
  693. a 640x480 image onto the screen is distinctly faster.  This doesn't seem
  694. that it should be the case.  This was on a machine with a NuBus video card.
  695.  
  696. Is there something that must be done to set up Nubus for big transfer of
  697. data that will speed writes across NuBus beyond CopyBits levels?  I ache
  698. to have some fast (very fast) graphics routines in my library.  Of course
  699. these routines will be current-machine dependent and may not work on 
  700. future models of Macintosh, but my concern is only with current Mac models.
  701.  
  702. Ideally, one would be able to circumvent all ToolBox and ColorQuickDraw
  703. routines, and simply use video memory and the video card's CLUT to do the
  704. animation.  This should be lightning fast, and would allow the Mac to offer
  705. things like multiple sprite planes, multi-layer scrolling, etc etc.  There's
  706. no reason why a lightning fast game couldn't be designed for the Macintosh,
  707. but it seems one would have to get around most of Apple's ROM code for
  708. graphics to do so.
  709.  
  710. While this is very ugly and I'm a heretic for suggesting it, it is nonetheless
  711. attractive to me.
  712.  
  713. Has anyone had any success in doing things along these lines?
  714.  
  715. Bill Budge (of RasterBlaster and Pinball Construction Set for the Apple II 
  716. fame) commented when he first got his Mac 128 (it was a re-release model
  717. held together entirely by plexiglass and sporting only an external drive) that
  718. if the Macintosh were ever to support technologically hip game software, it 
  719. would require the use of custom graphics routines.  This was back when there
  720. was no Color Quickdraw, and only 8Mhz 68000's, but he recognized this very
  721. early on.
  722.  
  723. No doubt for Color QuickDraw this still holds, especially on 16Mhz color
  724. machines.   
  725.  
  726. Anyone else out there yearn for what could be called "FrankenDraw"?  
  727.  
  728. respectfully,
  729.  
  730. Steve
  731. wras@ccwf.cc.utexas.edu
  732.  
  733.  
  734.  
  735. - -------------------------
  736.  
  737. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  738. Subject:  Fast Graphics cont...
  739. Date: 31 Jan 92 20:57:04 GMT
  740. Organization: Kalamazoo College
  741.  
  742. In article <65948@ut-emx.uucp> wras@ccwf.cc.utexas.edu (Steve Mariotti) writes:
  743. >
  744. >What about the possibility of doing something as un-IM-compliant as writing
  745. >directly to video memory?
  746. >
  747.  
  748. Here's as good a place to trumpet something that everyone should know.
  749. When you write directly to the screen, surround the calls with a
  750. ShieldCursor and a ShowCursor.  This lets some third-party monitors
  751. (like the Radius Color Pivot) know that you're messing with that area.
  752. If you do not do this, these monitors will keep your data in a virtual
  753. screen and not display it until later.
  754.  
  755. Because all QuickDraw routines call ShieldCursor and ShowCursor, the
  756. card designers figured they could patch those calls to let the monitor
  757. know when it has to update the actual screen.  Unfortunately, very few
  758. people seem to know about it...
  759.  
  760. Meanwhile...
  761.  
  762. >I've tried this with a tight loop that does 
  763. >nothing but fill an 8 bit screen with a single value (0xAA).  This is not
  764. >as instantaneous as I thought!  In fact, it seems that doing a CopyBits of
  765. >a 640x480 image onto the screen is distinctly faster.  This doesn't seem
  766. >that it should be the case.
  767.  
  768. Possibly you're writing all the values that don't show on the screen?
  769. (right-left) != rowBytes, you know.
  770.  
  771. >Ideally, one would be able to circumvent all ToolBox and ColorQuickDraw
  772. >routines, and simply use video memory and the video card's CLUT to do the
  773. >animation.  This should be lightning fast, and would allow the Mac to offer
  774. >things like multiple sprite planes, multi-layer scrolling, etc etc.  There's
  775. >no reason why a lightning fast game couldn't be designed for the Macintosh,
  776. >but it seems one would have to get around most of Apple's ROM code for
  777. >graphics to do so.
  778.  
  779. I don't think so.  Things like sprites and scrolling backgrounds are
  780. built into hardware; they have custom chips.  I don't believe any video
  781. card made for the Mac has any such thing available.  You'd still have to
  782. rely on the 680x0 to push the bits to the video memory.
  783.  
  784. Most existing video games don't use QuickDraw.
  785. -- 
  786.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  787.  Kzoo randomly kills all my mail;  if I don't acknowledge, try resending.    
  788.  
  789.  
  790.  
  791. - -------------------------
  792.  
  793. From: mhkohne@jupiter.cs.umbc.edu (Michael Kohne)
  794. Subject:  Fast Graphics cont...
  795. Date: 1 Feb 92 15:07:11 GMT
  796. Organization: University of Maryland Baltimore Campus, Computer Science Department
  797.  
  798. In article <1992Jan31.205704.10445@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  799. >
  800. >Here's as good a place to trumpet something that everyone should know.
  801. >When you write directly to the screen, surround the calls with a
  802. >ShieldCursor and a ShowCursor.  This lets some third-party monitors
  803. >(like the Radius Color Pivot) know that you're messing with that area.
  804. >If you do not do this, these monitors will keep your data in a virtual
  805. >screen and not display it until later.
  806. >
  807. >Because all QuickDraw routines call ShieldCursor and ShowCursor, the
  808. >card designers figured they could patch those calls to let the monitor
  809. >know when it has to update the actual screen.  Unfortunately, very few
  810. >people seem to know about it...
  811. >
  812. You know, I saw Ben Haller's post on this subject, and inserted Shileld and 
  813. ShowCursor calls into my init ClickShow. Now, I've gotten some wierd results.
  814. Ocassionally, when I click, I'll get an imprint of the cursor on the screen. 
  815. this usually happens when clicking buttons and the like. Any ideas as to
  816. what could be going on? (Note the my direct-to-screen drawing is done from a
  817. postevent patch.) I'm wondering if ShieldCursor is cumulative (if I call it
  818. twice with 2 different rectangles, does the second over-ride the first?)
  819.  
  820.  
  821.  
  822. -- 
  823. "Pope" Q.E.D         Lord High Jabberwocky
  824. Michael Kohne        mhkohne@jupiter.cs.umbc.edu
  825. Coded Message: FIME NDUXXMS MZP FTQ EXUFTK FAHQE SKDQ MZP SUYNXQ UZ FTQ IMNQ.
  826.  
  827.  
  828.  
  829. - -------------------------
  830.  
  831. From: ozma@kuhub.cc.ukans.edu
  832. Subject:  Fast Graphics cont...
  833. Date: 2 Feb 92 04:57:38 GMT
  834. Organization: University of Kansas Academic Computing Services
  835.  
  836. >>I've tried this with a tight loop that does 
  837. >>nothing but fill an 8 bit screen with a single value (0xAA).  This is not
  838. >>as instantaneous as I thought!  In fact, it seems that doing a CopyBits of
  839. >>a 640x480 image onto the screen is distinctly faster.  This doesn't seem
  840. >>that it should be the case.
  841. > Possibly you're writing all the values that don't show on the screen?
  842. > (right-left) != rowBytes, you know.
  843.  
  844. You're also moving a byte at a time.  Try the loop with 0xAAAAAAAA.
  845.  
  846. john calhoun-
  847.  
  848.  
  849.  
  850. - -------------------------
  851.  
  852. From: amanda@visix.com (Amanda Walker)
  853. Subject:  Fast Graphics cont...
  854. Date: 3 Feb 92 15:09:25 GMT
  855. Organization: Visix Software Inc., Reston, VA
  856.  
  857. ozma@kuhub.cc.ukans.edu writes:
  858. > You're also moving a byte at a time.  Try the loop with 0xAAAAAAAA.
  859.  
  860. Or even better, load up 6 data registers with 0xAAAAAAAA and do
  861. MOVEM.L inside a DBRA loop (on anything greater than a 68000, this will
  862. run completely out of the instruction cache, giving you the maximum
  863. possible transfer rate).
  864.  
  865.  
  866. Amanda Walker                              amanda@visix.com
  867. Visix Software Inc.                    ...!uunet!visix!amanda
  868. -- 
  869. "This is a one line proof...if we start sufficiently far to the left."
  870.         --- peter@cbmvax.cbm.commodore.com
  871.  
  872.  
  873.  
  874. - -------------------------
  875.  
  876. From: lim@iris.ucdavis.edu (Lloyd Lim)
  877. Subject:  Fast Graphics cont...
  878. Date: 4 Feb 92 01:12:46 GMT
  879. Organization: U.C. Davis - Department of Electrical Engineering and Computer Science
  880.  
  881. In article <1992Jan31.205704.10445@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  882. >
  883. >Here's as good a place to trumpet something that everyone should know.
  884. >When you write directly to the screen, surround the calls with a
  885. >ShieldCursor and a ShowCursor.  This lets some third-party monitors
  886. >(like the Radius Color Pivot) know that you're messing with that area.
  887. >If you do not do this, these monitors will keep your data in a virtual
  888. >screen and not display it until later.
  889.  
  890. I'm also trying to do this and having problems.  No matter what rect I use
  891. ShieldCursor shields a rect approximately (0,0,550,350).  I use rects in
  892. global coordinates with an offset of (0,0).  This is with System 6.0.5,
  893. an Apple 13" RGB, and no INITs.
  894.  
  895. Any idea what's the probably stupid mistake I'm making?  It wouldn't matter
  896. if a dialog is on the screen, would it?
  897.  
  898. +++
  899. Lloyd Lim     Internet: lim@iris.cs.ucdavis.edu
  900.               America Online: LimUnltd
  901.               Compuserve: 72647,660
  902.               US Mail: 224 Lysle Leach Hall, U.C. Davis, Davis, CA 95616
  903.  
  904.  
  905.  
  906. - -------------------------
  907.  
  908. From: joagre@meryl.docs.uu.se (Joakim Greben|)
  909. Subject: Fast graphics...
  910. Date: 9 Feb 92 20:09:28 GMT
  911. Organization: UDAC, Uppsala, Sweden
  912.  
  913. Some month ago there was a discussion about drawing directly
  914. to the screen. As a final result someone posted a routine in C that
  915. did it in 8 bits color. I thought that I saved the source - but tough luck!
  916. I would appreciate if someone reposted the source for me (thank you!)
  917. - -
  918. Joakim Greben| at ICU in Sweden
  919. joagre@csd.uu.se
  920. - -
  921.  
  922.  
  923.  
  924. ---------------------------
  925.  
  926. End of C.S.M.P. Digest
  927. **********************
  928.